const express = require('express');
const cors = require('cors');
const morgan = require('morgan');
const {db_connect} = require('./model');
const app = express();

app.use(express.json());
app.use(express.urlencoded());
app.use(cors());
app.use(morgan('dev'));
app.use('/api/v1', require('./router'));


const PORT = process.env.PORT || 3000;

db_connect()
    .then(() => {
        app.listen(PORT, () => {
            console.log(`服务器运行在 ${PORT} 端口上`);
        });
    })
    .catch(err => {
        console.log("数据库链接失败：", err);
    })